package com.kiki.favorite.mapper;

import java.util.List;
import com.kiki.favorite.domain.Favorite;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

/**
 * 用户收藏Mapper接口
 * 
 * @author 林志毅
 * @date 2025-01-08
 */
public interface FavoriteMapper 
{
    /**
     * 查询用户收藏
     * 
     * @param favoriteId 用户收藏主键
     * @return 用户收藏
     */
    public Favorite selectFavoriteByFavoriteId(Long favoriteId);

    /**
     * 查询用户收藏列表
     * 
     * @param favorite 用户收藏
     * @return 用户收藏集合
     */
    public List<Favorite> selectFavoriteList(Favorite favorite);

    /**
     * 新增用户收藏
     * 
     * @param favorite 用户收藏
     * @return 结果
     */
    public int insertFavorite(Favorite favorite);

    /**
     * 修改用户收藏
     * 
     * @param favorite 用户收藏
     * @return 结果
     */
    public int updateFavorite(Favorite favorite);

    /**
     * 删除用户收藏
     * 
     * @param favoriteId 用户收藏主键
     * @return 结果
     */
    public int deleteFavoriteByFavoriteId(Long favoriteId);

    /**
     * 批量删除用户收藏
     * 
     * @param favoriteIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFavoriteByFavoriteIds(Long[] favoriteIds);

    @Select("select song_id from favorite where user_id = #{userId}")
    List<Long> listFavoriteByUserId(Long userId);

    @Select("select song_id from favorite where user_id = #{userId}")
    List<Long> getFavoriteSongsByUserId(int userId);

    @Select("select count(1) from favorite where user_id = #{userId} and song_id = #{songId}")
    Boolean getExistFavorite(Favorite favorite);

    @Delete("delete from favorite where user_id = #{userId} and song_id = #{songId}")
    int deleteFavorite2(Favorite favorite);

    @Select("select count(1) from favorite where user_id = #{userId} and song_id = #{songId}")
    int getFavoriteStatus(Favorite favorite);
}
